<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html lang="zh-CN">
  
  <head>
    
    <%@ include file="/WEB-INF/include/meta.jsp"%>
    <%@ include file="/WEB-INF/include/css.jsp"%>
    
  </head>
  <!-- end header -->
  <body>
    <div class="page-group">
      <div class="page page-current">
        
        <header class="bar bar-nav fs-header-small">
          <a href="${ctx.host}/profile" class="icon icon-left pull-left"></a>
          <h1 class="title">我的卡券</h1>
        </header>
        
        <div class="content">
          <c:if test="${empty coupons}">
            <p class="text-center" style="margin-top: 5rem; color: #999;">您暂无优惠券哦</p>
          </c:if>
          <c:forEach var="coupon" items="${coupons}">
            <c:choose>
              <c:when test="${coupon.status.claimed && coupon.restDay > 0}">
              <a href="${ctx.host}/profile/coupon/${coupon.id}">
                <div class="list-block media-list coupon">
                  <ul>
                    <li>
                      <label class="label-checkbox item-content">
                        <div class="item-inner">
                          <div class="item-text">
                            <h2 class="coupon-amount">
                              <c:choose>
                                <c:when test="${coupon.template.discountType.percent}">全额</c:when>
                                <c:otherwise>
                                  <span>￥</span>${coupon.amount / 100}
                                </c:otherwise>
                              </c:choose>
                            </h2>
                            <div class="coupon-info">
                              <p class="coupon-title">${coupon.templateName}</p>
                              <p class="coupon-date">有效时间：
                                <fmt:formatDate value="${coupon.effectiveStartDate}" pattern="yyyy-MM-dd"/>
                              &nbsp;至&nbsp;<fmt:formatDate value="${coupon.effectiveEndDate}" pattern="yyyy-MM-dd"/></p>
                            </div>
                          </div>
                        </div>
                      </label>
                    </li>
                  </ul>
                </div>
                </a>
              </c:when>
              <c:when test="${coupon.status.claimed && coupon.restDay <= 0}">
                <div class="list-block media-list coupon used">
                  <ul>
                    <li>
                      <label class="label-checkbox item-content">
                        <div class="item-inner">
                          <div class="item-text">
                            <h2 class="coupon-amount">
                              <c:choose>
                                <c:when test="${coupon.template.discountType.percent}">全额</c:when>
                                <c:otherwise>
                                  <span>￥</span>${coupon.amount / 100}
                                </c:otherwise>
                              </c:choose>
                            </h2>
                            <div class="coupon-info">
                              <p class="coupon-title">${coupon.templateName}</p>
                              <p>已过期</p>
                            </div>
                          </div>
                        </div>
                      </label>
                    </li>
                  </ul>
                </div>
              </c:when>
              <c:when test="${coupon.status.occupied}">
                <div class="list-block media-list coupon used">
                  <ul>
                    <li>
                      <label class="label-checkbox item-content">
                        <div class="item-inner">
                          <div class="item-text">
                            <h2 class="coupon-amount">
                              <c:choose>
                                <c:when test="${coupon.template.discountType.percent}">全额</c:when>
                                <c:otherwise>
                                  <span>￥</span>${coupon.amount / 100}
                                </c:otherwise>
                              </c:choose>
                            </h2>
                            <div class="coupon-info">
                              <p class="coupon-title">${coupon.templateName}</p>
                              <p>该优惠券已被占用</p>
                            </div>
                          </div>
                        </div>
                      </label>
                    </li>
                  </ul>
                </div>
              </c:when>
              <c:when test="${coupon.status.used}">
                <div class="list-block media-list coupon used">
                  <ul>
                    <li>
                      <label class="label-checkbox item-content">
                        <div class="item-inner">
                          <div class="item-text">
                            <h2 class="coupon-amount">
                              <c:choose>
                                <c:when test="${coupon.template.discountType.percent}">全额</c:when>
                                <c:otherwise>
                                  <span>￥</span>${coupon.amount / 100}
                                </c:otherwise>
                              </c:choose>
                            </h2>
                            <div class="coupon-info">
                              <p class="coupon-title">${coupon.templateName}</p>
                              <p>已使用</p>
                            </div>
                          </div>
                        </div>
                      </label>
                    </li>
                  </ul>
                </div>
              </c:when>
            </c:choose>
          </c:forEach>
        </div>
        <!-- End Content -->
        
      </div>
    </div>
    
    <%@ include file="/WEB-INF/include/script.jsp"%>
    
  </body>
</html>